<template>
	<!-- 新建商品 -->
	<view class="class">
		<navigator url="./guige">
			<view class="flex-c" style="height: 140rpx;">
				<view class="flex-cb one" style="">
					<view>规格实例</view>
					<text class="cuIcon-right"></text>
				</view>
			</view>
		</navigator>
		<view class="head">
			<view class="title">
				<text class="text">主营类型<text class="text-red">*</text></text>
				<view class="view flex-cb">
					{{mainBusiness[0].name}}
				</view>
			</view>
			<view class="title">
				<text class="text">是否限购<text class="text-red">*</text></text>
				<view class="view limit">
					<view class="limit-item" @click="is_limit = 1">
						<text>是</text>
						<text class="cuIcon-roundcheckfill" style="color: #1cd6ae;" v-if="is_limit ==1 "></text>
						<text class="cuIcon-round" v-else></text>
					</view>
					<view class="limit-item" @click="is_limit = 0">
						<text>否</text>
						<text class="cuIcon-roundcheckfill" style="color: #1cd6ae;" v-if="is_limit ==0 "></text>
						<text class="cuIcon-round" v-else></text>
					</view>
				</view>
			</view>
			<view class="title" v-if="is_limit==1">
				<text class="text">限购数量<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="text" placeholder="请输入限购数量" class="input" v-model="limit_number">
				</view>
			</view>
			<view class="title">
				<text class="text">新人限购<text class="text-red">*</text></text>
				<view class="view limit">
					<view class="limit-item" @click="is_new_limit = 1">
						<text>是</text>
						<text class="cuIcon-roundcheckfill" style="color: #1cd6ae;" v-if="is_new_limit ==1 "></text>
						<text class="cuIcon-round" v-else></text>
					</view>
					<view class="limit-item" @click="is_new_limit = 0">
						<text>否</text>
						<text class="cuIcon-roundcheckfill" style="color: #1cd6ae;" v-if="is_new_limit ==0 "></text>
						<text class="cuIcon-round" v-else></text>
					</view>
				</view>
			</view>
			<view class="title">
				<text class="text">经营分类<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<picker mode="selector" :range="picker3" @change="PickerChange3">
						<view class="flex-cb Price">
							<view>{{index3>-1?picker3[index3]:'选择经营分类'}}</view>
							<text class="cuIcon-unfold"></text>
						</view>
					</picker>
				</view>
			</view>
			<view class="title">
				<text class="text">商品分类<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<picker mode="selector" :range="picker2" @change="PickerChange2">
						<view class="flex-cb Price">
							<view>{{index2>-1?picker2[index2]:'选择商品分类'}}</view>
							<text class="cuIcon-unfold"></text>
						</view>
					</picker>
				</view>
			</view>
			<view class="title">
				<text class="text">商品名称<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="text" placeholder="请输入商品名称" class="input" v-model="title">
				</view>
			</view>
			<view class="title">
				<text class="text">商品简介<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="text" placeholder="请输入商品简介" class="input" v-model="desc">
				</view>
			</view>
			<view class="image">
				<text class="text">上传商品主图（{{img.length}}/5）<text class="text-red">*</text></text>
				<scroll-view scroll-X="true">
					<view class="div flex-cb">
						<view class="image_div " style="padding: 50rpx 108rpx;" v-if="img.length == 0"
							@click="handleImg(1)">
							<image src="/static/pageA/xc.png" mode=""></image>
						</view>
						<view class="image_div img " v-else v-for="(i,j) in img" :key="j">
							<image :src="isurl[0]?url+i:i" mode="" @click="detele(j)"></image>
						</view>

					</view>
				</scroll-view>
			</view>
			<view class="title" v-if="serverType == 2">
				<text class="text">商品运费</text>
				<view class="view" style="background: none;">
					<view class="weixinzf flex-cb" @click="express_fee = 1">
						<view class="weixin_img flex align-center">
							<text>免运费</text>
						</view>
						<text class="cuIcon-roundcheckfill" v-if="express_fee ==1 "></text>
						<text class="cuIcon-round" v-else></text>
					</view>
					<view class="weixinzf flex-cb yhk" @click="express_fee = 0">
						<view class="weixin_img flex align-center">
							<text>设置运费（运营管理里面设置）</text>
						</view>
						<text class="cuIcon-roundcheckfill" v-if="express_fee == 0"></text>
						<text class="cuIcon-round" v-else></text>
					</view>
				</view>
			</view>
			<view class="image">
				<text class="text">商品详情（1张商品图片或者1个视频）<text class="text-red">*</text></text>
				<scroll-view scroll-X="true">
					<view class="div flex align-center justify-between">
						<view class="image_div " style="padding: 50rpx 108rpx;" v-if="imgs.src == ''"
							@click="handleImg(2)">
							<image src="/static/pageA/xc.png" mode=""></image>
						</view>
						<view class="image_div img " v-else @click="detele1(1)">
							<image :src="isurl[1]?url+imgs.src:imgs.src" mode="" v-if="imgs.type==1"></image>
							<video :src="isurl[1]?url+imgs.src:imgs.src" v-if="imgs.type ==2"></video>
						</view>

					</view>
				</scroll-view>
			</view>
			<!-- <view class="title">
				<view class="flex align-center" @click="help">
					<text class="text">赠送积分比例{{user.give_point_rate}}%({{user.is_point==0?'未开通':user.is_point==1?'已开通':user.is_point==2?'申请中':'已拒绝，原因：'+user.is_point_yuanyin}})</text>
					<text class="cuIcon-question" style="margin-left: 10rpx;"></text>
				</view>
				<view class="view flex-cb">
					<input type="number" placeholder="请输入要赠送积分" :value="point" class="input" @blur="handleJF">
				</view>
			</view> -->
		</view>




		<!-- 商品规格 -->
		<!-- v-if="main_id == 2" -->
		<view class="" v-for="(t,m) in spec_list" :key="m" v-if="serverType != 2">
			<view class="head1  head2 bg-white">
				<view class="title">
					<view class="text flex-cb">
						<text>商品规格<text class="text-red">*</text></text>
						<view class="flex-cb">
							<view class="A" @click="handleX(1)">-</view>
							<view class="B" @click="handleX(2)">+</view>
						</view>
					</view>
					<view class="view flex-cb">
						<input type="text" placeholder="请输入商品规格(如:份量)" class="input" v-model="t.spec_name">
					</view>
				</view>
			</view>
			<view class="head head1" v-for="(i,j) in t.item_list" :key="j">
				<view class="title">
					<text class="text">规格项<text class="text-red">*</text></text>
					<view class="view flex-cb">
						<input type="text" placeholder="请输入规格(例如:大份/小份)" class="input" v-model="i.item_name">
					</view>
				</view>
				<view class="title">
					<text class="text">商品原价<text class="text-red">*</text></text>
					<view class="view flex-cb">
						<input type="digit" placeholder="请输入商品原价" class="input" maxlength="10" v-model="i.price">
					</view>
				</view>
				<view class="title">
					<text class="text">商品会员价<text class="text-red">*</text></text>
					<view class="view flex-cb">
						<input type="digit" placeholder="请输入商品会员价" class="input" maxlength="10" v-model="i.vip_price">
					</view>
				</view>
				<view class="title">
					<text class="text">积分抵扣比例<text class="text-red">*</text></text>
					<view class=" flex-cb" style="height: 80rpx;padding-left: 10rpx;">
						<text>每100积分抵扣<text class="text-red">*</text></text>
						<input type="number" placeholder="请输入积分抵扣金额" class="input" maxlength="10"
							v-model="i['100_point_deduct_amount']" style="background:#F8F8F8 ;height: 100%;">
						<text>元</text>
					</view>
				</view>
				<view class="title">
					<text class="text">积分最大抵扣金额<text class="text-red">*</text></text>
					<view class="view flex-cb">
						<input type="number" placeholder="请输入积分抵扣金额" class="input" maxlength="10"
							v-model="i.point_deduct_max_amount">
					</view>
				</view>
				<view class="title">
					<view class="flex align-center" @click="help">
						<text
							class="text">赠送积分{{user.give_point_rate || 0}}%({{user.is_point==0?'未开通':user.is_point==1?'已开通':user.is_point==2?'申请中':'已拒绝，原因：'+ (user.is_point_yuanyin?user.is_point_yuanyin:'无')}})</text>
						<text class="cuIcon-question" style="margin-left: 10rpx;"></text>
					</view>
					<view class="view flex-cb">
						<input type="number" placeholder="请输入要赠送积分" class="input" v-model="i.point" @blur="handleJF">
					</view>
				</view>
				<view class="title">
					<text class="text">商品库存<text class="text-red">*</text></text>
					<view class="view flex-cb">
						<input type="number" placeholder="请输入商品库存" class="input" maxlength="10" v-model="i.stock">
					</view>
				</view>
			</view>
		</view>

		<!-- 服务商品创建 -->
		<view class="head head1" v-if="serverType == 2">
			<view class="title">
				<text class="text">商品原价<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="digit" placeholder="请输入商品原价" class="input" maxlength="10" v-model="fuwuxm.price">
				</view>
			</view>
			<view class="title">
				<text class="text">商品会员价<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="digit" placeholder="请输入商品会员价" class="input" maxlength="10"
						v-model="fuwuxm.vip_service">
				</view>
			</view>
			<view class="title">
				<text class="text">积分抵扣比例<text class="text-red">*</text></text>
				<view class=" flex-cb" style="height: 80rpx;padding-left: 10rpx;">
					<text>每100积分抵扣<text class="text-red">*</text></text>
					<input type="number" placeholder="请输入积分抵扣金额" class="input" maxlength="10"
						v-model="fuwuxm.point_deduct_amount" style="background:#F8F8F8 ;height: 100%;">
					<text>元</text>
				</view>
			</view>
			<view class="title">
				<text class="text">积分最大抵扣金额<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="number" placeholder="请输入积分最大抵扣金额" class="input" maxlength="10"
						v-model="fuwuxm.point_deduct_max_amount">
				</view>
			</view>
			<view class="title">
				<view class="flex align-center" @click="help">
					<text
						class="text">赠送积分{{user.give_point_rate}}%({{user.is_point==0?'未开通':user.is_point==1?'已开通':user.is_point==2?'申请中':'已拒绝，原因：'+user.is_point_yuanyin}})</text>
					<text class="cuIcon-question" style="margin-left: 10rpx;margin-top: 0;"></text>
				</view>
				<view class="view flex-cb">
					<input type="number" placeholder="请输入要赠送积分" class="input" v-model="fuwuxm.point" @blur="handleJF">
				</view>
			</view>
			<view class="title">
				<text class="text">商品库存<text class="text-red">*</text></text>
				<view class="view flex-cb">
					<input type="number" placeholder="请输入商品库存" class="input" maxlength="10" v-model="fuwuxm.stock">
				</view>
			</view>
		</view>

		<!-- 商品属性 -->
		<view>
			<navigator url="./attribute" class="flex-c" style="height: 120rpx;margin-top: 10rpx;">
				<view class="flex-cb  bg-white" style="width: 100%;height: 100rpx;padding: 0 20rpx;">
					<view>商品属性</view>
					<text class="cuIcon-right"></text>
				</view>
			</navigator>
			<view class="head1  head2 bg-white" v-for="(it,i) in attribute" :key="i" v-if="it.attribute_name">
				<view class="title">
					<view class="text">
						<text>{{it.attribute_name}}</text>
						<view class="flex-c" style="margin-top: 20rpx;">
							<view class="flex-c" v-for="(i,j) in it.name" :key="j"
								style="height: 65rpx; width: 200rpx;background: #e6e6e6;border-radius: 10rpx;margin-right: 10rpx;">
								{{i}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--  -->
		<view v-show="serverType == 2">
			<navigator url="./attribute?title=服务项目" class="flex-c" style="height: 120rpx;margin-top: 10rpx;">
				<view class="flex-cb  bg-white" style="width: 100%;height: 100rpx;padding: 0 20rpx 0 36rpx;">
					<view>服务项目<text class="text-red">*</text></view>
					<text class="cuIcon-right"></text>
				</view>
			</navigator>
			<view class="head1  head2 bg-white">
				<text>内容项</text>
				<view class="title flex-c">
					<view class="flex-c" v-for="(i,j) in fuwuxm.items" :key="j"
						style="height: 65rpx; width: 200rpx;background: #e6e6e6;border-radius: 10rpx;margin-right: 10rpx;">
						{{i.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="button flex-c" v-if="!goods.name" @click="handleQD(1)">确定</view>
		<view class="button flex-c" v-else @click="handleQD(2)">修改</view>
		<!-- 协议 -->
		<view class="agreement modal_view" v-if="isshow">
			<view class="agreement_text bg-white">
				<scroll-view scroll-y="true" class="screen-swiper">
					<view v-html="text"></view>
				</scroll-view>
				<view class="colse flex align-center">
					<!-- <image src="/static/gou.png" mode="" v-if="isshow" ></image> -->
					<image src="/static/gou2.png" mode="" @click="handleShow"></image>
					<text>阅读并同意《协议条款》</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// import {
	// 	mutations as uniIdMutations
	// } from '@/uni_modules/uni-id-pages/common/store.js';
	export default {
		data() {
			return {
				// 主营对象
				mainBusiness: {},
				// id 类型 下标控制
				arrid1: [],
				arrid2: [],
				arrid3: [],
				url: '',
				isurl: [0, 0], //是否加url
				goods: {},
				main_id: null, //主营类型id
				text: '', //协议
				isshow: 0,
				index: -1, //主营分类下标
				type: [], //主营类型
				is_limit: 0, //是否限购
				is_new_limit: 0,
				limit_number: '', //限购数量
				index1: -1, //商品分类下标
				index2: -1, //商品分类下标
				index3: -1, //经营分类下标
				picker1: [], //主营
				picker2: [], //商品分类
				picker3: [], //经营分类
				type2: [], //商品分类
				type3: [], //经营分类
				id: 0,
				img: [], //图片显示(主图)

				cover: [], //商品主图
				title: '', //商品名称
				desc: '', //商品简介
				express_fee: 1, //运费 1 免运费 0设置运费
				imgs: {
					type: 1,
					src: ''
				}, // 商品详情图片&视频显示
				images: {
					type: 1,
					src: ''
				}, //商品详情 视频
				point: 0, //积分
				ispoint: 0, //是否开通积分
				user: '',
				main_idx: '',
				listKey: '',
				attribute: [], //商品属性{"attribute_name":"辣度","item_list":["不辣","微辣","中辣","特辣"]}
				arr: [{
					"item_name": "",
					"price": "",
					"vip_price": "",
					"100_point_deduct_amount": '',
					"point_deduct_max_amount": "",
					"point": "",
					"stock": '',
				}, ],
				spec_list: [ //商品规格
					{
						"spec_name": "",
						item_list: [{
							'item_name': "",
							'price': "",
							'vip_price': "",
							"100_point_deduct_amount": '',
							'point_deduct_max_amount': "",
							"point": '',
							'stock': '',
						}, ],
					},
				],
				fuwuxm: {
					"items": [],
					"price": 8,
					"vip_service": 0.01,
					"point_deduct_amount": 100,
					"point_deduct_max_amount": 10,
					"point": 0,
					"stock": 100
				}, //服务项目
				serverType: 1,
			};
		},
		onLoad(option) {
			if (option.key) {
				this.listKey = option.key
			}
			this.url = this.$base
			this.main_id = option.main_id
			if (option.bjdata) {
				this.playUpdate(option)
			}else{
				// 获取商家基本信息
				this.getBusinessInfo()
				
				// 获取商家主营，并获取经营分类列表
				this.getMainbusiness()
			}
			
			// 获取商品分类
			this.getGoodsType()
			// 获取积分规则
			this.getPointRule()
			console.log(this.mainBusiness, 'this.mainBusiness');
			// // 经营回显
			// if (this.goods.category_id != undefined) {
			// 	this.$api.merchant_cate_list({}, this.goods.category_id).then(res => {
			// 		if (res.code == 200001) {
			// 			this.type3 = res.data
			// 			for (let i = 0; i < res.data.length; i++) {
			// 				this.picker3[i] = res.data[i].name
			// 				this.arrid3[i] = res.data[i].id
			// 			}
			// 		}
			// 		this.arrid3.forEach((i, k) => {
			// 			i == this.second_category_id ? this.index3 = k : ''
			// 		})
			// 	})
			// }
			// this.$api.merchant_cate_list({},this.type).then(res =>{
			// 	console.log("获取到的经营分类0000000000",res)
			// 	if(res.code == 200001){
			// 		this.type2 = res.data
			// 		for (let i = 0; i < res.data.length; i++) {
			// 			this.picker2[i] = res.data[i].name
			// 		}
			// 	}
			// 	console.log("赋值分类名称",this.picker3)
			// })

		},
		onShow() {
			if (uni.getStorageSync('sex')) {
				this.attribute = uni.getStorageSync('sex')
			}
			if (uni.getStorageSync('fwxm')) {
				this.fuwuxm.items = uni.getStorageSync('fwxm')
			}
		},
		methods: {
			// 获取积分规则
			getPointRule() {
				this.$api.point_rule().then(res => {
					if (res.code == 200001) {
						this.text = res.data
					}
				})
			},
			// 获取商品分类
			getGoodsType() {
				this.$api.goods_categories().then(res => { //商品分类
					if (res.code == 200001) {
						this.type2 = res.data
						for (let i = 0; i < res.data.length; i++) {
							this.picker2[i] = res.data[i].name
							this.arrid2[i] = res.data[i].id
						}
					}
					if (this.goods.goods_category_id != undefined) {
						this.arrid2.forEach((i, k) => {
							i == this.goods.goods_category_id ? this.index2 = k : ''
						})
					}
				})
			},
			// 获取商家基本信息
			getBusinessInfo() {
				this.$api.merchant().then(res => {
					this.user = res.data
					this.main_idx = res.data.main_id
					this.serverType = res.data.main.type
				})
			},
			// 修改商品页面渲染
			playUpdate(option) {
				uni.setNavigationBarTitle({
					title: '修改商品'
				})
				this.goods = JSON.parse(option.bjdata)
				console.log();
				this.type = this.goods.category_id //主营id
				this.$api.merchants_type({ //主营类
				}, true).then(res => {
					this.type1 = res.data
					this.mainBusiness = this.type1.filter(res => res.id == this.type)
					this.$api.merchant_cate_list({}, this.type).then(res => {
						if (res.code == 200001) {
							this.type3 = res.data
							for (let i = 0; i < res.data.length; i++) {
								this.picker3[i] = res.data[i].name
								this.arrid3[i] = res.data[i].id
							}
						}
						this.arrid3.forEach((i, k) => {
							i == this.second_category_id ? this.index3 = k : ''
						})
					})
					// if (res.code == 200001) {
					// 	for (let i = 0; i < res.data.length; i++) {
					// 		for (let i = 0; i < res.data.length; i++) {
					// 			this.picker1[i] = res.data[i].name
					// 			this.arrid1[i] = res.data[i].id
					// 		}
					// 	}
					// }
					// console.log(this.goods.category_id);
					// if (this.goods.category_id != undefined) {
					// 	console.log(this.arrid1);
					// 	this.arrid1.forEach((i, k) => {
					// 		i == this.goods.category_id ? this.index1 = k : ''
					// 	})
					// }

				})
				this.is_limit = this.goods.is_limit //是否限购
				this.is_new_limit = this.goods.is_new_limit //是否限购
				this.limit_number = this.goods.limit_number //限购数量 隐藏
				this.main_id = this.goods.goods_category_id //经营分类id
				this.second_category_id = this.goods.second_category_id //商品分类id
				this.title = this.goods.name //商品名称
				this.desc = this.goods.intro //简介
				this.express_fee = this.goods.is_free_express_fee
				this.point = this.goods.point
				if (this.serverType != 2) {
					this.attribute = this.goods.sku.attribute_list
					this.spec_list = this.goods.sku.spec_list
				} else {
					this.fuwuxm.items = this.goods.service.items
					this.fuwuxm.point_deduct_amount = this.goods.service.point_deduct_amount
					this.fuwuxm.point_deduct_max_amount = this.goods.service.point_deduct_max_amount
					this.fuwuxm.price = this.goods.service.price
					this.fuwuxm.vip_service = this.goods.service.vip_price
					this.fuwuxm.stock = this.goods.service.stock
				}

				this.cover = this.goods.main_images //商品主图
				this.img = this.goods.main_images //商品主图显示
				this.imgs.src = this.goods.detail //商品详情图&视频
				this.images.src = this.goods.detail //商品详情图&视频
				this.isurl[0] = 1
				this.isurl[1] = 1
			},
			// 获取商家主营，并获取经营分类列表
			getMainbusiness() {
				this.$api.merchants_type({ //主营类
				}, true).then(res => {
					this.type1 = res.data
					this.mainBusiness = this.type1.filter(res => res.id == this.main_id)
					this.$api.merchant_cate_list({}, this.main_id).then(res => {
						if (res.code == 200001) {
							this.type3 = res.data
							for (let i = 0; i < res.data.length; i++) {
								this.picker3[i] = res.data[i].name
								this.arrid3[i] = res.data[i].id
							}
						}
						this.arrid3.forEach((i, k) => {
							i == this.second_category_id ? this.index3 = k : ''
						})
					})
					// if (res.code == 200001) {
					// 	for (let i = 0; i < res.data.length; i++) {
					// 		for (let i = 0; i < res.data.length; i++) {
					// 			this.picker1[i] = res.data[i].name
					// 			this.arrid1[i] = res.data[i].id
					// 		}
					// 	}
					// }
					// console.log(this.goods.category_id);
					// if (this.goods.category_id != undefined) {
					// 	console.log(this.arrid1);
					// 	this.arrid1.forEach((i, k) => {
					// 		i == this.goods.category_id ? this.index1 = k : ''
					// 	})
					// }

				})
			},
			help() {
				this.$utils.tips('积分示例：商品价格x赠送积分，如15x20%=3积分，此时最多赠送3积分')
			},
			handleImg(i) { //上传商品主图  & 商品图片|视频
				let that = this
				if (i == 1) {
					uni.chooseImage({
						count: 5, //默认9
						success: (res) => {
							that.isurl[0] = 0
							that.img = res.tempFilePaths
							uni.showLoading({
								title: '正在上传',
								mask: true
							});
							for (let i = 0; i < res.tempFilePaths.length; i++) {
								this.$api.upImage(res.tempFilePaths[i]).then(Res => {
									that.cover.push(Res)
								});
							}
							uni.hideLoading();
						}
					});
				} else {
					uni.chooseMedia({
						count: 1,
						mediaType: ['image', 'video'],
						maxDuration: 30,
						camera: 'back',
						success(res) {
							that.isurl[1] = 0
							if (res.tempFiles.size / (1024 * 1024) >= 50) {
								that.$utils.tips('只能上传50M以内的视频或者图片')
							} else {
								that.imgs.src = res.tempFiles[0].tempFilePath
								uni.showLoading({
									title: '正在上传',
									mask: true
								});
								if (res.tempFiles[0].fileType == "image") {
									that.$api.upImage(res.tempFiles[0].tempFilePath).then(Res => {
										if (Res) {
											that.images.src = Res
										}
									});
								} else {
									that.imgs.type = 2
									that.images.type = 2 //默认1图片2 视 频
									that.$api.upImage(res.tempFiles[0].tempFilePath).then(Res => {
										if (Res) {
											that.images.src = Res
										}
									});
								}
								uni.hideLoading();
							}


						}
					})
				}
			},
			detele(i) { //删除图片
				this.img.splice(i, 1)
				this.cover.splice(i, 1)
			},
			detele1() {
				this.imgs.src = ''
				this.images.src = ''
			},
			PickerChange1(e) {
				this.$api.merchant_cate_list({}, this.arrid1[e.detail.value]).then(res => {
					if (res.code == 200001) {
						this.type3 = res.data
						for (let i = 0; i < res.data.length; i++) {
							this.picker3[i] = res.data[i].name
						}
					}
				})
			},
			PickerChange2(e) {
				this.index2 = e.detail.value
			},
			PickerChange3(e) {
				this.index3 = e.detail.value
				this.goods.second_category_id = this.arrid3[e.detail.value]
			},
			handleYF(e) {
				this.express_fee = e.detail.value

			},
			handleJF(e) {
				if (this.user.is_point == 0) {
					this.handlepoint()
					return
				}
				if (this.user.is_point == -1) {
					this.handlepoint()
					return
				}
				this.point = e.detail.value
			},
			handleX(i) {
				if (i == 1) {
					if (this.spec_list[0].item_list.length == 1) {
						return
					} else {
						this.spec_list[0].item_list.splice(this.spec_list[0].item_list.length - 1, 1)
					}

				} else {
					if (this.spec_list[0].item_list.length != 4) {
						this.spec_list[0].item_list = [...this.spec_list[0].item_list, ...this.arr]
					} else {
						uni.showToast({
							icon: "none",
							title: '不能再加了'
						})
					}
				}
			},
			handleQD(i) { //确定
				let than = this

				if (this.index2 == -1) {
					this.$utils.tips('请选择商品分类')
					return
				}

				if (this.index3 == -1) {
					this.$utils.tips('请选择经营分类')
					return
				}
				if (this.title == '') {
					this.$utils.tips('请输入商品名称')
					return
				}
				if (this.desc == '') {
					this.$utils.tips('请输入商品简介')
					return
				}
				if (this.cover == '') {
					this.$utils.tips('请上传商品主图')
					return
				}
				if (this.images.length == 0) {
					this.$utils.tips('请上传商品图片或视频')
					return
				}
				// if(this.point == ''){
				// 	this.$utils.tips('请输入赠送积分')
				// 	return
				// }
				// let t = []//临时数据
				// for (let i = 0; i < this.fuwuxm.items.length; i++) {
				// 	t[i] = this.fuwuxm.items[i].name
				// }
				// this.fuwuxm.items = t
				if (i == 1) { //创建商品
					if (this.serverType != 2) {
						if (this.spec_list[0].spec_name == '') {
							this.$utils.tips('商品规格还未填写')
							return
						}
						for (let i = 0; i < this.spec_list[0].item_list.length; i++) {
							if (!this.$utils.Money(this.spec_list[0].item_list[i].price)) {
								this.$utils.tips('商品原价价格有误')
								return
							}
							if (!this.$utils.Money(this.spec_list[0].item_list[i].vip_price)) {
								this.$utils.tips('商品会员价有误')
								return
							}
							if (this.spec_list[0].item_list[i]['100_point_deduct_amount'] == '') {
								this.$utils.tips('每100积分抵扣还未填写')
								return
							}
							if (this.spec_list[0].item_list[i].item_name == '') {
								this.$utils.tips('规格项还未填写')
								return
							}
							if (this.spec_list[0].item_list[i].point_deduct_max_amount == '') {
								this.$utils.tips('积分抵扣金额还未填写')
								return
							}
							if (this.spec_list[0].item_list[i].give_point == '') {
								this.$utils.tips('赠送积分还未填写')
								return
							}
							if (this.spec_list[0].item_list[i].point > parseInt((this.user.give_point_rate / 100) * this
									.spec_list[0].item_list[i].price)) {
								this.$utils.tips('第' + i + 1 + '项赠送积分超出赠送积分比例')
								return
							}
						}
						// if (this.attribute.length == 0) {
						// 	this.$utils.tips('商品属性还未填写')
						// 	return
						// }
						let arr = {
							attribute_list: this.attribute, //商品属性
							category_id: this.mainBusiness[0].id, //经营分类id
							goods_category_id: this.type2[this.index2].id, //商品分类id
							second_category_id: this.type3[this.index3].id, //经营分类id
							main_images: this.cover, //商品主图
							name: this.title, //商品名称
							intro: this.desc, //商品简介
							is_free_express_fee: this.express_fee, //运费 1 免运费 0设置运费
							detail: this.images.src, //商品详情视频||图片
							is_limit: this.is_limit, //是否限购
							is_new_limit: this.is_new_limit, //是否限购
							limit_number: this.limit_number, //限购数量
							spec_list: this.spec_list, //商品规格
							point: this.point, //积分
							// second_category_id:'',
						}
						this.$api.merchant_goods_add(arr, true).then(res => {
							if (res.code == 200001) {
								uni.showModal({
									title: '商品创建成功',
									showCancel: false,
									success(res) {
										if (res.confirm) {
											uni.removeStorageSync('sex')
											uni.navigateBack()
										}
									}
								})
							}
							if (res.code == 812405) {
								this.$utils.tips('' + res.message)
								return
							}
						})
					} else {
						if (this.fuwuxm.items.length == 0) {
							this.$utils.tips('服务项还未填写')
							return
						}
						if (!this.$utils.Money(this.fuwuxm.price)) {
							this.$utils.tips('商品原价价格有误')
							return
						}
						if (!this.$utils.Money(this.fuwuxm.vip_service)) {
							this.$utils.tips('商品会员价有误')
							return
						}
						// if(this.fuwuxm.point == ''){
						// 	this.$utils.tips('赠送积分未填写')
						// 	return
						// }
						if (this.fuwuxm.point > parseInt((this.user.give_point_rate / 100) * this.fuwuxm.price)) {
							this.$utils.tips('赠送积分已超过赠送比例')
							return
						}

						this.$api.merchant_goods_add({
							category_id: this.mainBusiness[0].id, //经营分类id
							goods_category_id: this.type2[this.index2].id, //商品分类id
							second_category_id: this.type3[this.index3].id, //经营分类id
							// spec_list: this.spec_list, //商品规8格
							service: this.fuwuxm, //商品规格
							attribute_list: this.attribute, //商品属性
							main_images: this.cover, //商品主图
							name: this.title, //商品名称
							intro: this.desc, //商品简介
							is_free_express_fee: this.express_fee, //运费 1 免运费 0设置运费
							detail: this.images.src, //商品详情视频||图片
							is_limit: this.is_limit, //是否限购
							is_new_limit: this.is_new_limit, //是否限购
							limit_number: this.limit_number, //限购数量
							point: this.point, //积分
						}, true).then(res => {
							if (res.code == 200001) {
								uni.showModal({
									title: '商品创建成功',
									showCancel: false,
									success(res) {
										if (res.confirm) {
											uni.removeStorageSync('sex')
											uni.navigateBack()
										}
									}
								})
							}
							if (res.code == 812405) {
								this.$utils.tips('' + res.message)
								return
							}
						})
					}
				} else { //编辑商品
					if (this.serverType != 2) {
						if (this.spec_list[0].spec_name == '') {
							this.$utils.tips('商品规格还未填写')
							return
						}
						for (let i = 0; i < this.spec_list[0].item_list.length; i++) {
							if (!this.$utils.Money(this.spec_list[0].item_list[i].price)) {
								this.$utils.tips('商品原价价格有误')
								return
							}
							if (!this.$utils.Money(this.spec_list[0].item_list[i].vip_price)) {
								this.$utils.tips('商品会员价有误')
								return
							}
							if (this.spec_list[0].item_list[i]['100_point_deduct_amount'] == '') {
								this.$utils.tips('每100积分抵扣还未填写')
								return
							}
							if (this.spec_list[0].item_list[i].item_name == '') {
								this.$utils.tips('规格项还未填写')
								return
							}
							if (this.spec_list[0].item_list[i].point_deduct_max_amount == '') {
								this.$utils.tips('积分抵扣金额还未填写')
								return
							}
							// if(this.spec_list[0].item_list[i].give_point == ''){
							// 	this.$utils.tips('赠送积分还未填写')
							// 	return
							// }
							if (this.spec_list[0].item_list[i].point > parseInt((this.user.give_point_rate / 100) * this
									.spec_list[0].item_list[i].price)) {
								this.$utils.tips('第' + i + 1 + '项赠送积分超出赠送积分比例')
								return
							}
						}
						if (this.attribute.length == 0) {
							this.$utils.tips('商品属性还未填写')
							return
						}
						console.log(this.spec_list,'this.fuwuxmthis.fuwuxmthis.fuwuxmthis.fuwuxmthis.fuwuxmthis.fuwuxmthis.fuwuxmthis.fuwuxmthis.fuwuxm');
						this.$api.merchant_goods_edit({
							category_id: this.goods.category_id, //经营分类id
							goods_category_id: this.goods.goods_category_id, //商品分类id 二
							second_category_id: this.goods.second_category_id, //经营分类id
							spec_list: this.spec_list, //商品规格
							attribute_list: this.attribute, //商品属性
							main_images: this.cover, //商品主图
							name: this.title, //商品名称
							intro: this.desc, //商品简介
							is_limit: this.is_limit,
							is_new_limit: this.is_new_limit, //是否限购
							limit_number: this.limit_number,
							is_free_express_fee: this.express_fee, //运费 1 免运费 0设置运费
							detail: this.images.src, //商品详情视频||图片
							// point:this.point,//积分
						}, this.goods.id, true).then(res => {
							if (res.code == 200001) {
								uni.showModal({
									title: '商品修改成功',
									showCancel: false,
									success(res) {
										if (res.confirm) {
											uni.removeStorageSync('sex')
											uni.navigateBack()
										}
									}
								})
							}
							if (res.code == 812405) {
								this.$utils.tips('' + res.message)
								return
							}
						})
					} else {
						if (this.fuwuxm.items.length == 0) {
							this.$utils.tips('服务项还未填写')
							return
						}
						if (!this.$utils.Money(this.fuwuxm.price)) {
							this.$utils.tips('商品原价价格有误')
							return
						}
						if (!this.$utils.Money(this.fuwuxm.vip_service)) {
							this.$utils.tips('商品会员价有误')
							return
						}
						// if(this.fuwuxm.point == ''){
						// 	this.$utils.tips('赠送积分未填写')
						// 	return
						// }
						if (this.fuwuxm.point > parseInt((this.user.give_point_rate / 100) * this.fuwuxm.price)) {
							this.$utils.tips('赠送积分已超过赠送比例')
							return
						}
						this.$api.merchant_goods_edit({
							category_id: this.goods.category_id, //经营分类id
							goods_category_id: this.goods.goods_category_id, //商品分类id 二
							second_category_id: this.goods.second_category_id, //经营分类id
							main_images: this.cover, //商品主图
							name: this.title, //商品名称
							intro: this.desc, //商品简介
							is_limit: this.is_limit,
							is_new_limit: this.is_new_limit, //是否限购
							limit_number: this.limit_number,
							is_free_express_fee: this.express_fee, //运费 1 免运费 0设置运费
							detail: this.images.src, //商品详情视频||图片
							point: this.point, //积分
							service: this.fuwuxm, //服务项目
						}, this.goods.id, true).then(res => {
							if (res.code == 200001) {
								uni.showModal({
									title: '商品修改成功',
									showCancel: false,
									success(res) {
										if (res.confirm) {
											uni.removeStorageSync('sex')
											uni.navigateBack()
										}
									}
								})
							}
							if (res.code == 812405) {
								this.$utils.tips('' + res.message)
								return
							}
						})
					}
				}
			},
			handleShow() {
				this.isshow = 0
				this.ispoint = 1
			},
			handledata() {},
			handlepoint() {
				let _this = this
				uni.showModal({
					title: "赠送积分",
					content: "商家暂未开通赠送积分，是否开通",
					confirmColor: "#1CD699",
					success(res) {
						if (res.confirm) {
							_this.$api.merchants_change_shop_point().then(res => {
								//0未开通 1已开通 2 申请中 -1拒绝
								_this.$api.merchant().then(res => {
									_this.user = res.data
								})
								uni.setStorageSync('show', res.data[0].is_point)
							})
							_this.isshow = 1
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.class {
		margin-top: 1rpx;
	}

	.cuIcon-question {
		margin-top: 30rpx;
	}

	.text-red {
		font-size: 45rpx;
		position: relative;
		top: 10rpx;
		left: 5rpx;
	}

	.limit {
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}

	.limit-item {
		display: flex;
		align-items: center;
		margin-right: 50rpx;
	}

	.limit-item>text:first-child {
		margin-right: 20rpx;
	}

	.one {
		height: 100rpx;
		background: #d7f5eb;
		width: 710rpx;
		border-radius: 10rpx;
		padding: 0 30rpx;
		color: #1CD699;
	}

	.text {
		height: 37rpx;
		color: #333333;
		font-size: 26rpx;
		font-weight: 500;
		margin-left: 10rpx;
	}

	.head {
		width: 750rpx;
		min-height: 864rpx;
		padding: 30rpx 32rpx 76rpx 36rpx;
		background: #FFFFFF;

		.title {
			margin-top: 30rpx;

			.view {
				width: 682rpx;
				min-height: 80rpx;
				margin-top: 20rpx;
				background: #F8F8F8;
				border-radius: 10rpx;
				padding-left: 22rpx;
				padding-right: 32rpx;

				.Price,
				.input {
					width: 630rpx;
				}

				.input {}
			}

		}

		.image {
			margin-top: 30rpx;

			.image_div {
				margin-top: 30rpx;
				margin-right: 20rpx;
				width: 309rpx;
				height: 194rpx;
				background: #F9F9F9;
				box-shadow: 0px 1px 5px 1px rgba(0, 0, 0, 0.09);
				border-radius: 10rpx;

				image {
					width: 94rpx;
					height: 94rpx;
				}
			}

			.img {

				// overflow: hidden;
				image,
				video {
					width: 309rpx;
					height: 194rpx;
				}

			}

			scroll-view {
				width: 100%;
				height: 230rpx;
				overflow: hidden;
				white-space: nowrap;

				.div {
					// width: 100%;
					// height: 230rpx;
					// display: inline-block;
				}
			}
		}
	}

	.head1 {
		margin-top: 10rpx;
		height: auto;
	}

	.head2 {
		min-height: 180rpx;
		padding: 20rpx 32rpx 20rpx 36rpx;

		.title {
			margin-top: 30rpx;

			.view {
				width: 682rpx;
				height: 80rpx;
				margin-top: 20rpx;
				background: #F8F8F8;
				border-radius: 10rpx;
				padding-left: 22rpx;
				padding-right: 32rpx;

				.Price,
				.input {
					width: 630rpx;
				}

				.input {}
			}

		}

		.A,
		.B {
			width: 80rpx;
			height: 50rpx;
			border-radius: 10rpx;
			text-align: center;
			font-size: 40rpx;
		}

		.A {
			border: #e6e6e6 solid 1rpx;
			color: #999;
			margin-right: 20rpx;
		}

		.B {
			background: #d7f5eb;
			color: #1cd699;
			border: #1CD699 solid 1rpx;
		}
	}

	.button {
		width: 648rpx;
		height: 80rpx;
		background: #1CD699;
		border-radius: 10rpx;
		color: #fff;
		font-weight: bold;
		font-size: 28rpx;
		margin: 80rpx auto;
	}

	.agreement {
		position: fixed;
		z-index: 999;

		.agreement_text {
			width: 100%;
			height: calc(100vh - 70rpx);
			position: absolute;
			bottom: 0;

			.screen-swiper {
				height: calc(100vh - 110rpx);

				view {
					padding: 29rpx 26rpx 0 26rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #666666;
					line-height: 70rpx;
				}
			}

			.colse {
				position: fixed;
				z-index: 1;
				bottom: 20rpx;
				width: 100%;
				height: 110rpx;
				background: #FFFFFF;

				image {
					width: 40rpx;
					height: 40rpx;
					margin-left: 48rpx;
					margin-right: 20rpx;
				}
			}
		}
	}

	.weixinzf {
		height: 100rpx;

		// padding-right: 10rpx;
		.cuIcon-weixin {
			width: 50rpx;
			height: 50rpx;
			color: #FFFFFF;
			background: #3EB135;
			border-radius: 50%;
			margin-bottom: 20rpx;
		}

		text {
			font-size: 32rpx;
			// margin-left: 19rpx;
		}

		.cuIcon-roundcheckfill,
		.cuIcon-round {
			font-size: 44rpx;
			color: #1CD699 !important;
		}

		.cuIcon-round {
			color: #CCCCCC;
		}
	}
</style>